package com.qk.management.controller;

import com.qk.common.Result;
import com.qk.dto.user.UserLoginDto;
import com.qk.vo.user.LoginResultVo;
import com.qk.entity.User;
import com.qk.management.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


/*
 *  @author SHCJ
 *  @created 2025/10/6 21:56
 *  @description
 */
@Slf4j
@RestController
public class LoginController {
    @Autowired
    private UserService userService;
    @PostMapping("/login")
    public Result login(@RequestBody UserLoginDto userLoginDto) {
        log.info("用户登录:{}", userLoginDto);
        LoginResultVo loginResult = userService.login(userLoginDto);
        if (loginResult != null) {
            return Result.success(loginResult);
        } else {
            return Result.error("用户名或密码错误");
        }
    }
}
